//
//  QDDiseaseDetailView.m
//  QuickDoctor
//
//  Created by 李伟 on 2016/12/21.
//  Copyright © 2016年 Eric. All rights reserved.
//

#import "QDDiseaseDetailView.h"
#import "QDDisSubDivideVC.h"
#import "QDdisComplicationVC.h"
#import "QDFocusController.h"
#import "QDDisTreatmentVC.h"
@interface QDDiseaseDetailView()
//疾病细分
@property (weak, nonatomic) IBOutlet UITextField *tf_disSubDivide;

//并发症
@property (weak, nonatomic) IBOutlet UITextField *tf_disComplication;

//4个选择按钮
@property (weak, nonatomic) IBOutlet UIButton *btn_isConfirmed;

@property (weak, nonatomic) IBOutlet UIButton *btn_UnConfirmed;

@property (weak, nonatomic) IBOutlet UIButton *btn_isAccept;

//是否确诊
@property (weak, nonatomic) IBOutlet UITextField *tf_isConfirmed;

//治疗方式view
@property (weak, nonatomic) IBOutlet UIButton *btn_unAccept;

//是否接受治疗
@property (weak, nonatomic) IBOutlet UITextField *tf_isReceived;
@property (weak, nonatomic) IBOutlet UIView *v_treatmentView;

//治疗方式
@property (weak, nonatomic) IBOutlet UITextField *tf_treatment;

//匹配到的医生数
@property (weak, nonatomic) IBOutlet UILabel *lb_doctorNum;


@end
@implementation QDDiseaseDetailView
#pragma mark
#pragma mark - 初始化方法
+ (instancetype)diseaseDetailView
{
    UINib *nib = [UINib nibWithNibName:NSStringFromClass(self) bundle:nil];
    return [nib instantiateWithOwner:nil options:nil].lastObject;
    
}


#pragma mark
#pragma mark - 点击"疾病细分"
- (IBAction)clickDisSubDivide:(id)sender {

    //疾病细分控制器
    QDDisSubDivideVC *disSubDivi = [[QDDisSubDivideVC alloc]init];
    disSubDivi.ci1_id = [self ci1_id];
    //block回调
    disSubDivi.backBlock = ^(NSString *str)
    {
        _tf_disSubDivide.text = str;
    };
    
    [[self getCurrentViewC].navigationController pushViewController:disSubDivi animated:YES];
    
}


#pragma mark
#pragma mark - 点击"选择并发症"
- (IBAction)clickDisComplication:(UIButton *)sender {
    //并发症控制器
    QDdisComplicationVC *disComplication = [[QDdisComplicationVC alloc]init];
    //block回调
    disComplication.backBlock = ^(NSArray<NSString*>* orderArray)
    {
        //数组转字符串并拼接
        self.tf_disComplication.text = [orderArray componentsJoinedByString:@"、"];
    };

    [[self getCurrentViewC].navigationController pushViewController:disComplication animated:YES];
}

//点击已确诊
- (IBAction)clickIsConfirmed:(UIButton *)sender {
    
    self.btn_UnConfirmed.selected = NO;
    sender.selected = YES;
    self.tf_isConfirmed.text = @"已确诊";
}

//点击疑似症状
- (IBAction)clickUnConfirmed:(UIButton *)sender {
    
    self.btn_isConfirmed.selected = NO;
    sender.selected = YES;
    self.tf_isConfirmed.text = @"疑似症状";
}

//点击接受过
- (IBAction)clickIsAccept:(UIButton*)sender {
    
    self.btn_unAccept.selected = NO;
    sender.selected = YES;
    self.tf_isReceived.text = @"接受过";
    self.v_treatmentView.hidden = NO;
}
//点击未接受过
- (IBAction)clickUnAccept:(UIButton*)sender {
    self.btn_isAccept.selected = NO;
    sender.selected = YES;
    self.tf_isReceived.text = @"未接受过";
    self.v_treatmentView.hidden = YES;
}
#pragma mark
#pragma mark - 点击选择治疗方式
- (IBAction)clickTreatment:(id)sender {
    
    QDDisTreatmentVC *treatmentVC = [[QDDisTreatmentVC alloc]init];
    //block回调
    treatmentVC.backBlock = ^(NSString *str)
    {
        _tf_treatment.text = str;
    };

    [[self getCurrentViewC].navigationController pushViewController:treatmentVC animated:YES];
}

#pragma mark
#pragma mark - 点击"就医申请"
- (IBAction)clickTreatApply:(UIButton *)sender {
    //跳转到关注医生界面
    QDFocusController *focusC = [[QDFocusController alloc]init];
    
    [[self getCurrentViewC].navigationController pushViewController:focusC animated:YES];
    
    
}

#pragma mark
#pragma mark - 获取view的当前控制器
- (UIViewController*)getCurrentViewC
{
    for (UIView * next = [self superview];next; next = next.superview) {
        
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController*)nextResponder;
        }
    }
    return nil;
}

//ci1_id
- (NSNumber*)ci1_id
{
    NSNumber *ci1_id;
    if ([_lb_disType.text isEqualToString:@"肿 瘤"])
    {
        ci1_id = @1;
    }
    if ([_lb_disType.text isEqualToString:@"心血管"])
    {
        ci1_id = @2;
    }
    if ([_lb_disType.text isEqualToString:@"神经科"])
    {
        ci1_id = @3;
    }
    if ([_lb_disType.text isEqualToString:@"血液科"])
    {
        ci1_id = @4;
    }
    if ([_lb_disType.text isEqualToString:@"骨 科"])
    {
        ci1_id = @5;
    }
    return ci1_id;
}
@end
